package com.lee.boot.batch.processor;

import com.lee.boot.batch.common.YesOrNoEnum;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.batch.MyBatisCursorItemReader;
import org.mybatis.spring.batch.builder.MyBatisCursorItemReaderBuilder;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.builder.JpaPagingItemReaderBuilder;

import javax.sql.DataSource;


public class FileProcessor implements ItemProcessor {

    private final String value = YesOrNoEnum.YES.getValue();

    @Override
    public Object process(Object o) throws Exception {
        return null;
    }

    /**
     * 使用mybatis从数据库中读数据的item
     *
     * @param sqlSessionFactory
     * @return
     */
    public ItemReader getMybatisItemReader(SqlSessionFactory sqlSessionFactory) {
        MyBatisCursorItemReader<Object> build =
                new MyBatisCursorItemReaderBuilder<>()
                        .sqlSessionFactory(sqlSessionFactory)
                        // mapper的id
                        .queryId("getEntityByUsername").build();

        return build;
    }

    public ItemReader getTextFileItemReader() {
        System.out.println("aaaaaa");
        return null;
    }

    public void getN() {
        YesOrNoEnum no = YesOrNoEnum.NO;

        switch (no) {
            case YES :
                break;

            default:
                System.out.println("aaaa");
                break;

        }
    }


}
